package com.lis.scf.entity;

import javax.persistence.*;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 企业信息完善表实体类
 * 存储企业的详细补充信息，如经营地址、经营范围等
 */
@Data
@Entity
@Table(name = "enterprise_info")
@DynamicUpdate // 动态更新，只更新修改过的字段
public class EnterpriseInfo implements java.io.Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 记录ID（主键）
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

    /**
     * 关联企业ID（外键关联company表）
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", nullable = false)
    private Company company;

    /**
     * 企业经营地址
     */
    @Column(name = "business_address", length = 200)
    private String businessAddress;

    /**
     * 企业经营范围
     */
    @Column(name = "business_scope", columnDefinition = "TEXT")
    private String businessScope;

    /**
     * 企业资产规模（单位：万元）
     */
    @Column(name = "asset_scale", precision = 15, scale = 2)
    private BigDecimal assetScale;

    /**
     * 操作员证件号
     */
    @Column(name = "operator_id_number", length = 50)
    private String operatorIdNumber;

    /**
     * 操作员手机号
     */
    @Column(name = "operator_mobile", length = 20)
    private String operatorMobile;

    /**
     * 信息更新时间（自动更新）
     */
    @Column(name = "update_time", updatable = false)
    @org.hibernate.annotations.CreationTimestamp
    private LocalDateTime updateTime;

    /**
     * 重写toString方法，避免懒加载异常
     */
    @Override
    public String toString() {
        return "EnterpriseInfo{" +
                "id=" + id +
                ", businessAddress='" + businessAddress + '\'' +
                ", businessScope='" + businessScope + '\'' +
                ", assetScale=" + assetScale +
                '}';
    }
}
